package com.example.voicechat

import android.util.Log

object LogUtils {
    private const val TAG = "ljf_VoiceChat"
    private var isDebug = true  // 控制是否打印调试日志

    @JvmStatic  // 添加这个注解使Java代码可以静态调用
    @JvmOverloads  // 添加这个注解支持默认参数
    fun e(tag: String, message: String, throwable: Throwable? = null) {
        if (throwable != null) {
            Log.e("$TAG-$tag", message, throwable)
        } else {
            Log.e("$TAG-$tag", message)
        }
    }

    @JvmStatic
    fun d(tag: String, message: String) {
        if (isDebug) {
            Log.d("$TAG-$tag", message)
        }
    }

    @JvmStatic
    fun w(tag: String, message: String) {
        Log.w("$TAG-$tag", message)
    }

    @JvmStatic
    fun i(tag: String, message: String) {
        Log.i("$TAG-$tag", message)
    }

    // 设置是否打印调试日志
    @JvmStatic
    fun setDebug(debug: Boolean) {
        isDebug = debug
    }
} 